//
//  ClassSettingView.m
//  GIFShow
//
//  Created by lanou11air029 on 15/4/30.
//  Copyright (c) 2015年 CK. All rights reserved.
//

#import "ClassSettingView.h"

@interface ClassSettingView ()<UIGestureRecognizerDelegate>

@end
@implementation ClassSettingView
- (instancetype)init
{
    CGRect frame = [UIScreen mainScreen].bounds;
    frame.origin.y = 400;
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
    }
    return self;
}
-(void)setupSubviews{
    self.backgroundColor = [UIColor clearColor];
    for (int i = 0; i < 10; i++) {
        int row = i/3;
        int col = i%3;
        UIImageView * classView = [[UIImageView alloc]initWithFrame:CGRectMake(10 + col * 100, 10 + row * 60, 80, 40)];
        classView.backgroundColor = [UIColor yellowColor];
        classView.userInteractionEnabled = YES;
        [self addSubview:classView];
        classView.tag = i + 1000;
        UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(moveTheViewAction:)];
        [classView addGestureRecognizer:pan];
    }
}
-(void)moveTheViewAction:(UIPanGestureRecognizer *)panGes{
    panGes.view.center = [panGes locationInView:self];
    for (UIView * view in self.subviews) {
        if (view == panGes.view) {
            continue;
        }
        if (CGRectIntersectsRect(panGes.view.frame, view.frame)) {
            NSLog(@"%@与%@比尔相交",panGes.view, view);
        }
        
    }
}
-(void)animationToShow{
    CGRect frame = [UIScreen mainScreen].bounds;

    frame.origin.y = 64;

    [UIView animateWithDuration:0.7 animations:^{
        self.frame = frame;
        self.backgroundColor = [UIColor colorWithWhite:0.7 alpha:0.5];

    }];
}

-(void)removeFromSuperview{
    CGRect frame = [UIScreen mainScreen].bounds;
    
    frame.origin.y = 364;
    
[UIView animateWithDuration:1 animations:^{
    self.frame = frame;
} completion:^(BOOL finished) {
    [super removeFromSuperview];
}];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
